local dirAF ""~/Dropbox/Covid Info Survey/replication_package/""
local dirBZ ""
local dirEF ""
local dirVP ""C:/Users/pezone/AppData/Local/Dropbox/Dropbox/Covid Info Survey/replication_package/""
local dirVPmac ""/Users/vincenzopezone/Dropbox/Covid Info Survey/replication_package/""

cap cd `dirVPmac'
cap cd `dirAF'
cap cd `dirVP'

set graphics off
set scheme s1color


****************
*** Figure 1 ***
****************

use data_wave2 if sample_10==1,clear
	
gen pc=pc_10
	
label variable pc "PC1"
	
local Z  worried pc support_sofar
	
gen pessimistic_rev=pessimistic if revealed==1
	
gen pessimistic_norev=pessimistic if revealed==0	
	
	
local n=1
	
local w_rev ""
		
local w_norev ""
		
local both ""
			
foreach z in `Z' {
		
	
	if "`z'"=="support_sofar" {

		gen `z'5=support_sofar
	
	}
	
	else {
	
		xtile `z'5=`z',nq(5)
	
	}
			
	local p :  word `n' of `c(alpha)'
			
	local k : variable label `z'
							
	graph bar pessimistic_rev pessimistic_norev ,over(`z'5)  name(`z'_both,replace) title(`p'. `k') ytitle("")   legend( order(1 "Source Revealed" 2 "Source Not Revealed") )    bar(1, fcolor(navy%20))  bar(2, fcolor(navy))
			
	local both `both'  `z'_both
			
	local n = `n'+1
		
}
		
grc1leg `both',  cols(3)  legendfrom(worried_both) 

graph export  ./figures/figure_1.png,replace


****************
*** Figure 2 ***
****************

use data_wave2 if sample_10==1,clear

xtile p_lib_cons2=p_lib_cons,nq(2)

gen sur0=1 if p_lib_cons!=.
gen sur1=1 if p_lib_cons2==1
gen sur2=1 if p_lib_cons2==2
	
xtile p_lib_cons3=p_lib_cons,nq(3)

gen sur1_3=1 if p_lib_cons3==1
gen sur2_3=1 if p_lib_cons3==2
gen sur3_3=1 if p_lib_cons3==3



local controls_all        college retired unemployed employment_loss_hh income_scale health health_conditions  already_infected  ///
age_c n_old female married race_black race_asian hispanic own_house stock health_insurance risk_loving discount trust lockdown       

*** Fixed effects are day and headline order dummies
local fe i.date   i.region

*** Geographic controls: cases per capita, deaths per capita and unemployment rate at the country level
local geo_controls cases_pc deaths_pc ur10

local c1 `controls_all' `fe' `geo_controls' 

local C c1


label variable reliability "Reliability"
label variable informativeness "Informativeness"
label variable money_spent "\$ in Advertising"
label variable headline_ok "Headline Check"
label variable support "Lockdown Support"
label variable p_deaths_rev "{&Delta}Pr(Deaths>200k)"
label variable lib_rev_pess " "

label variable p_ur_rev "{&Delta}Pr(UR>20%)"

label variable p_inf_rev "{&Delta}Pr(Infected)"

label variable d_app "{&Delta}Pr(CT App)"




local depvar reliability informativeness headline_ok  money_spent /*  p_deaths_rev  support p_ur_rev sign_up p_inf_rev */

foreach c in `C' {
	
	local n = 1
	
	foreach y in `depvar' {
		
		if "`y'"=="support" {
				
			local h  support_sofar
			
	}
								
	else {
			
		local h ""
			
	}			
		
	local D 0 1 2
				
	foreach d in `D' {
		
		quietly reg `y'   pess_article revealed_after  pess_rev   lib pess_lib lib_rev lib_rev_pess ``c'' `h'   if  sample_10==1 & no3==1 & sur`d'==1,r

		est store `y'_`d'
			
	}
				
	local k : variable label `y'
		
	local p :  word `n' of `c(alpha)'
				
	coefplot  (`y'_0, label("All     ") mcolor(navy) bcolor(navy) ciopts(recast(rcap) color(navy))) ///
	(`y'_1, label(Low Surpr.) msymbol(S) mcolor(navy) bgcolor(navy) ciopts(recast(rcap) color(navy))) /// 
	(`y'_2, label(High Surpr.) msymbol(D) mcolor(navy) bcolor(navy) ciopts(recast(rcap) color(navy))), keep(lib_rev_pess) yline(0) vertical title(`p'. `k') name(`y',replace) ///
	legend(  cols(3) )
			
	local n=`n'+1
		
	}
		
}
	
grc1leg `depvar', cols(2) 

graph export ./figures/figure_2.png,replace




